\hypertarget{communicator_8c}{
\section{communicator.c File Reference}
\label{communicator_8c}\index{communicator.c@{communicator.c}}
}
Functions for communicating with the client.  


{\tt \#include \char`\"{}communicator.h\char`\"{}}\par
{\tt \#include \char`\"{}serial.h\char`\"{}}\par
{\tt \#include \char`\"{}dispatcher.h\char`\"{}}\par
\subsection*{Functions}
\begin{CompactItemize}
\item 
void \hyperlink{communicator_8c_5f81facb36f7b18c987fd9a735bef1e2}{init\_\-communicator} ()
\item 
void \hyperlink{communicator_8c_4e6ba7a57d22958d993db85dbc0c8539}{send\_\-command} (uint8\_\-t device, uint8\_\-t id, uint8\_\-t command, uint8\_\-t $\ast$data, uint8\_\-t data\_\-length)
\item 
void \hyperlink{communicator_8c_9af3047f6b1c4588ffa9ed98304e26e4}{reset\_\-transmission\_\-record} ()
\item 
uint8\_\-t \hyperlink{communicator_8c_97a5c39315f6153fafcc95ef4748a230}{add\_\-byte\_\-to\_\-transmission\_\-record} (uint8\_\-t byte)
\item 
\hyperlink{communicator_8c_084f0a9cf05b1877bd8a71a90dae7ff8}{ISR} (USART0\_\-RX\_\-vect)
\end{CompactItemize}
\subsection*{Variables}
\begin{CompactItemize}
\item 
uint8\_\-t \hyperlink{communicator_8c_2acf4a041654d74a8aa4eb1795e37d81}{buffer} \mbox{[}MAX\_\-MESSAGE\_\-LENGTH\mbox{]}
\item 
int8\_\-t \hyperlink{communicator_8c_cf7702759190e96e1c2e5b4675b05e00}{transmission\_\-length}
\item 
int8\_\-t \hyperlink{communicator_8c_c79d9888f0f90d5c620eb23abe49979e}{buffer\_\-index}
\end{CompactItemize}


\subsection{Detailed Description}
Functions for communicating with the client. 

\begin{Desc}
\item[Author:]Robert Breznak, Peter Kalauskas \end{Desc}


\subsection{Function Documentation}
\hypertarget{communicator_8c_97a5c39315f6153fafcc95ef4748a230}{
\index{communicator.c@{communicator.c}!add\_\-byte\_\-to\_\-transmission\_\-record@{add\_\-byte\_\-to\_\-transmission\_\-record}}
\index{add\_\-byte\_\-to\_\-transmission\_\-record@{add\_\-byte\_\-to\_\-transmission\_\-record}!communicator.c@{communicator.c}}
\subsubsection[{add\_\-byte\_\-to\_\-transmission\_\-record}]{\setlength{\rightskip}{0pt plus 5cm}uint8\_\-t add\_\-byte\_\-to\_\-transmission\_\-record (uint8\_\-t {\em byte})}}
\label{communicator_8c_97a5c39315f6153fafcc95ef4748a230}


Adds a byte to the transmission buffer. The byte's role in the transmission will be determined by the function. The byte may be invalidly placed (ie. it may not be the starting byte where a starting should be), a length byte (which is not added to the buffer), or it may be added to the buffer.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em byte}]The byte to be added to the transmission. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]uint8\_\-t 0 if this is the end of the transmission, 1 otherwise \end{Desc}
\begin{Desc}
\item[Author:]Peter Kalauskas \end{Desc}
\hypertarget{communicator_8c_5f81facb36f7b18c987fd9a735bef1e2}{
\index{communicator.c@{communicator.c}!init\_\-communicator@{init\_\-communicator}}
\index{init\_\-communicator@{init\_\-communicator}!communicator.c@{communicator.c}}
\subsubsection[{init\_\-communicator}]{\setlength{\rightskip}{0pt plus 5cm}void init\_\-communicator ()}}
\label{communicator_8c_5f81facb36f7b18c987fd9a735bef1e2}


Initializes the communicator.

\begin{Desc}
\item[Author:]Robert Breznak, Peter Kalauskas \end{Desc}
\hypertarget{communicator_8c_084f0a9cf05b1877bd8a71a90dae7ff8}{
\index{communicator.c@{communicator.c}!ISR@{ISR}}
\index{ISR@{ISR}!communicator.c@{communicator.c}}
\subsubsection[{ISR}]{\setlength{\rightskip}{0pt plus 5cm}ISR (USART0\_\-RX\_\-vect)}}
\label{communicator_8c_084f0a9cf05b1877bd8a71a90dae7ff8}


The interrupt for receiving UART communications

\begin{Desc}
\item[Returns:]Nothing \end{Desc}
\begin{Desc}
\item[Author:]Peter Kalauskas \end{Desc}
\hypertarget{communicator_8c_9af3047f6b1c4588ffa9ed98304e26e4}{
\index{communicator.c@{communicator.c}!reset\_\-transmission\_\-record@{reset\_\-transmission\_\-record}}
\index{reset\_\-transmission\_\-record@{reset\_\-transmission\_\-record}!communicator.c@{communicator.c}}
\subsubsection[{reset\_\-transmission\_\-record}]{\setlength{\rightskip}{0pt plus 5cm}void reset\_\-transmission\_\-record ()}}
\label{communicator_8c_9af3047f6b1c4588ffa9ed98304e26e4}


Clears the buffer and resets the index to 0.

\begin{Desc}
\item[Author:]Robert Breznak, Peter Kalauskas \end{Desc}
\hypertarget{communicator_8c_4e6ba7a57d22958d993db85dbc0c8539}{
\index{communicator.c@{communicator.c}!send\_\-command@{send\_\-command}}
\index{send\_\-command@{send\_\-command}!communicator.c@{communicator.c}}
\subsubsection[{send\_\-command}]{\setlength{\rightskip}{0pt plus 5cm}void send\_\-command (uint8\_\-t {\em device}, \/  uint8\_\-t {\em id}, \/  uint8\_\-t {\em command}, \/  uint8\_\-t $\ast$ {\em data}, \/  uint8\_\-t {\em data\_\-length})}}
\label{communicator_8c_4e6ba7a57d22958d993db85dbc0c8539}


Sends a function and data to the given device on the client. The client will interpret this as a Message object and pass it along to the correct device.

\begin{Desc}
\item[Author:]Robert Breznak, Peter Kalauskas \end{Desc}


\subsection{Variable Documentation}
\hypertarget{communicator_8c_2acf4a041654d74a8aa4eb1795e37d81}{
\index{communicator.c@{communicator.c}!buffer@{buffer}}
\index{buffer@{buffer}!communicator.c@{communicator.c}}
\subsubsection[{buffer}]{\setlength{\rightskip}{0pt plus 5cm}uint8\_\-t {\bf buffer}\mbox{[}MAX\_\-MESSAGE\_\-LENGTH\mbox{]}}}
\label{communicator_8c_2acf4a041654d74a8aa4eb1795e37d81}


The buffer for storing incoming transmissions. \hypertarget{communicator_8c_c79d9888f0f90d5c620eb23abe49979e}{
\index{communicator.c@{communicator.c}!buffer\_\-index@{buffer\_\-index}}
\index{buffer\_\-index@{buffer\_\-index}!communicator.c@{communicator.c}}
\subsubsection[{buffer\_\-index}]{\setlength{\rightskip}{0pt plus 5cm}int8\_\-t {\bf buffer\_\-index}}}
\label{communicator_8c_c79d9888f0f90d5c620eb23abe49979e}


The current index of the buffer. \hypertarget{communicator_8c_cf7702759190e96e1c2e5b4675b05e00}{
\index{communicator.c@{communicator.c}!transmission\_\-length@{transmission\_\-length}}
\index{transmission\_\-length@{transmission\_\-length}!communicator.c@{communicator.c}}
\subsubsection[{transmission\_\-length}]{\setlength{\rightskip}{0pt plus 5cm}int8\_\-t {\bf transmission\_\-length}}}
\label{communicator_8c_cf7702759190e96e1c2e5b4675b05e00}


The expected length of the transmission. This will be set to INVALID\_\-LENGTH by default. 